<!-- include tpl=head_lay -->
<div class="layui-card">
	<div class="layui-card-header" style="min-height:53px;line-height:53px;height:auto;">
		<form method="post" class="layui-form">
		<div class="layui-form-item">
			<div class="layui-inline">
				<select name="type" lay-filter="type">
					<option value="">{lang统计类型…}</option>
					<!-- loop from=$plist key=$key value=$value id=$tmpid -->
					<option value="{$key}"{if $type == $key} selected{/if}>{$value}</option>
					<!-- /loop -->
				</select>
			</div>
			<div class="layui-inline {if !$xlist}hide{/if}" data-id="line-x">
				<select name="x">
					<option value="">{lang请选择…}</option>
					<!-- loop from=$xlist key=$key value=$value id=$tmpid -->
					<option value="{$key}"{if $x == $key} selected{/if}>{$value}</option>
					<!-- /loop -->
				</select>
			</div>
			<div class="layui-inline {if !$ylist}hide{/if}" data-id="line-y">
				<ul class="layout">
				<!-- loop from=$ylist key=$key value=$value id=$tmpid -->
				<li><input type="checkbox" name="y[]" lay-ignore value="{$key}"{if $y && is_array($y) && in_array($key,$y) } checked{/if} /> {$value}</li>
				<!-- /loop -->
				</ul>
			</div>
			<div class="layui-inline {if !$zlist}hide{/if}" data-id="line-z">
				<select name="data_mode">
					<option value="">{lang计算方式…}</option>
					<option value="count"{if $data_mode == 'count'} selected{/if}>{lang数量计算（Count）}</option>
					<option value="sum"{if $data_mode == 'sum'} selected{/if}>{lang和计算（SUM）}</option>
				</select>
			</div>
			<div class="layui-inline">
				<div class="layui-input-inline" style="width:140px">
					<input type="text" name="startdate" id="startdate" class="layui-input" value="{$startdate}" placeholder="{lang开始时间}" />
				</div>
				<div class="layui-form-mid">~</div>
				<div class="layui-input-inline" style="width:140px">
					<input type="text" name="stopdate" id="stopdate" class="layui-input" value="{$stopdate}" placeholder="{lang结束时间}" />
				</div>
			</div>
			<div class="layui-inline">
				<div class="layui-input-inline">
					<select name="chart">
						<option value="">{lang图表模式…}</option>
						<option value="line"{if $chart == 'line'} selected{/if}>{lang折线图}</option>
						<option value="bar"{if $chart == 'bar'} selected{/if}>{lang柱状图}</option>
					</select>
				</div>
			</div>
			<div class="layui-inline">
				<button type="submit" class="layui-btn layui-btn-sm" >
					{lang开始统计}
				</button>
			</div>
		</div>
		</form>
	</div>
	<!-- if $y_title || $rslist -->
	<div class="layui-card-body">
		<!-- if $chart -->
		<div id="chart_main" class="layui-carousel" data-anim="fade" lay-filter="LAY-index-normcol" lay-anim="fade" style="width: 100%; height: 420px;"></div>
		<!-- /if -->
		<table class="layui-table">
			<thead>
			<tr>
				<th>{$x_title}</th>
				<!-- loop from=$y_title key=$key value=$value id=$tmpid -->
				<th name="y_title">{$value}</th>
				<!-- /loop -->
			</tr>
			</thead>
			<tbody>
			<!-- loop from=$rslist key=$key value=$value id=$tmpid -->
			<tr name="chart">
				<td class="center">{$value.x}</td>
				<!-- loop from=$y_title key=$k value=$v id=$idx -->
				<td class="center">{$value['y_'.$k]}</td>
				<!-- /loop -->
			</tr>
			<!-- /loop -->
			</tbody>
		</table>
	</div>
	<!-- /if -->
</div>
<!-- if $chart -->
<script type="text/javascript">
    $(document).ready(function(){
        var myChart = echarts.init(document.getElementById('chart_main'));
        var chart = "{$chart}";
        var data_x = new Array();
        var data_y = new Array();
        var y_title = new Array();
        var series_data = new Array();
        $("th[name=y_title]").each(function(i){
            y_title[i] = $(this).text();
            var tmp = {'name':y_title[i],'type':chart};
            var tmp_data = new Array();
            $("tr[name=chart]").each(function(m){
                var m_i = i+1;
                tmp_data[m] = $(this).find('td:eq('+m_i+')').text();
            });
            tmp.data = tmp_data;
            series_data[i] = tmp;
        });
        $("tr[name=chart]").each(function(i){
            data_x[i] = $(this).find('td:eq(0)').text();
        });
        var option = {
            title:{text:'{$lead_title}'},
            legend: {data:y_title},
            xAxis: {data: data_x},
            yAxis: {},
            series: series_data
        };
        myChart.setOption(option);
    });
</script>
<!-- /if -->
<!-- include tpl=foot_lay -->